local zhuangqi = fk.CreateSkill {
  name = "lingling__zhuangqi",
  dynamic_desc = function (self, player, lang)
    local strs = {"四","四","三","三","二"}
    local str = "准备阶段或结束阶段，你可以弃置一张红色非锦囊牌，令一名角色将手牌摸至"
    local num = math.min(Fk:currentRoom():getBanner("RoundCount") or 1, 5)
    str = str .. strs[num]
    str = str .. "张。（每过两轮该张数-1，至少两张）"
    return str
  end,
}

Fk:loadTranslationTable{
  ["lingling__zhuangqi"] = "壮气",
  [":lingling__zhuangqi"] = "准备阶段或结束阶段，你可以弃置一张红色非锦囊牌，令一名角色将手牌摸至四张。（每过两轮该张数-1，至少两张）",

  ["#lingling__zhuangqi-invoke"] = "壮气：你可以弃置一张红色非锦囊牌，然后令一名角色将手牌摸至%arg张",
  ["#lingling__zhuangqi-choose"] = "壮气：令一名角色将手牌摸至%arg张",
}

zhuangqi:addEffect(fk.EventPhaseStart, {
  anim_type = "support",
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(zhuangqi.name) and
      (player.phase == Player.Start or player.phase == Player.Finish) and
      not player:isNude()
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    local strs = {"四","四","三","三","二"}
    local str = strs[math.min(Fk:currentRoom():getBanner("RoundCount") or 1, 5)]
    local card = room:askToDiscard(player, {
      min_num = 1,
      max_num = 1,
      include_equip = true,
      skill_name = zhuangqi.name,
      pattern = ".|.|heart,diamond|.|.|^trick",
      prompt = "#lingling__zhuangqi-invoke:::"..str,
      cancelable = true,
      skip = true,
    })
    if #card > 0 then
      event:setCostData(self, {cards = card})
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local card = event:getCostData(self).cards[1]
    room:throwCard(card, zhuangqi.name, player, player)
    if player.dead then return end
    local strs = {"四","四","三","三","二"}
    local str = strs[math.min(Fk:currentRoom():getBanner("RoundCount") or 1, 5)]
    local nums = {4, 4, 3, 3, 2}
    local num = nums[math.min(Fk:currentRoom():getBanner("RoundCount") or 1, 5)]
    local targets = table.filter(room.alive_players, function (p)
      return p:getHandcardNum() < num
    end)
    if #targets > 0 then
      local to = room:askToChoosePlayers(player, {
        min_num = 1,
        max_num = 1,
        targets = targets,
        skill_name = zhuangqi.name,
        prompt = "#lingling__zhuangqi-choose:::"..str,
        cancelable = false,
      })[1]
      to:drawCards(num - to:getHandcardNum(), zhuangqi.name)
    end
  end,
})

return zhuangqi
